﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4DJackPot
{
    public partial class ResultBoxForm : UserControl
    {
        public Company company;
        Game gameInfo;
        string resultDateString = "";

        public ResultBoxForm()
        {
            InitializeComponent();
        }

        public ResultBoxForm(string companyIdString, string resultDateString)
        {
            company = new Company(companyIdString);
            this.resultDateString = resultDateString;
            InitializeComponent();

        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void ResultBoxForm_Load(object sender, EventArgs e)
        {
            // customer name setting
            this.lB_CompanyName.Text = company.companyNameString;
            // 로고 세팅
            if(company.companyLogoUrl.Equals("magnum"))
            {
                pB_logoImg.Image = global::_4DJackPot.Properties.Resources.magnum;
            }
            else if (company.companyLogoUrl.Equals("damacai"))
            {
                pB_logoImg.Image = global::_4DJackPot.Properties.Resources.damacai;
            }
            else
            {
                pB_logoImg.Image = global::_4DJackPot.Properties.Resources.toto;
            }
            if (resultDateString.Equals("last"))
            {
                if (company.isExistLastGame())
                {
                    gameInfo = company.GetLastGameInfo();
                    SetGameResult();
                }
                else
                {
                    SetEmptyResult();
                }
            }
            else
            {
                gameInfo = company.GetGameInfo(resultDateString);
                SetGameResult();
            }
        }
        private void SetGameResult()
        {
            this.lb_GameID.Text = "Game ID : " + gameInfo.gameIdString;
            this.lB_Date.Text = "Date : " + gameInfo.gameDrawDate;
            WinningNumbers winningNumbers = gameInfo.getWinningNumbers();
            
            this.lB_FirstPrize.Text = Int32.Parse(winningNumbers.FirstPrizeNumber).ToString("0000");
            this.lB_SecondPrize.Text = Int32.Parse(winningNumbers.SecondPrizeNumber).ToString("0000");
            this.lB_ThirdPrize.Text = Int32.Parse(winningNumbers.ThirdPrizeNumber).ToString("0000");
            this.lB_sp1.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[1]).ToString("0000");
            this.lB_sp2.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[2]).ToString("0000");
            this.lB_sp3.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[3]).ToString("0000");
            this.lB_sp4.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[4]).ToString("0000");
            this.lB_sp5.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[5]).ToString("0000");
            this.lB_sp6.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[6]).ToString("0000");
            this.lB_sp7.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[7]).ToString("0000");
            this.lB_sp8.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[8]).ToString("0000");
            this.lB_sp9.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[9]).ToString("0000");
            this.lB_sp10.Text = Int32.Parse(winningNumbers.SpecialPrizeNumbers[0]).ToString("0000");
            this.lB_cp1.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[1]).ToString("0000");
            this.lB_cp2.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[2]).ToString("0000");
            this.lB_cp3.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[3]).ToString("0000");
            this.lB_cp4.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[4]).ToString("0000");
            this.lB_cp5.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[5]).ToString("0000");
            this.lB_cp6.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[6]).ToString("0000");
            this.lB_cp7.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[7]).ToString("0000");
            this.lB_cp8.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[8]).ToString("0000");
            this.lB_cp9.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[9]).ToString("0000");
            this.lB_cp10.Text = Int32.Parse(winningNumbers.ConsolationPrizeNumbers[0]).ToString("0000");

        }
        private void SetEmptyResult()
        {
            this.lb_GameID.Text = "There is no Game Result.";
            this.lB_Date.Text = "";
            this.lB_FirstPrize.Text = "";
            this.lB_SecondPrize.Text = "";
            this.lB_ThirdPrize.Text = "";
            this.lB_sp1.Text = "";
            this.lB_sp2.Text = "";
            this.lB_sp3.Text = "";
            this.lB_sp4.Text = "";
            this.lB_sp5.Text = "";
            this.lB_sp6.Text = "";
            this.lB_sp7.Text = "";
            this.lB_sp8.Text = "";
            this.lB_sp9.Text = "";
            this.lB_sp10.Text = "";
            this.lB_cp1.Text = "";
            this.lB_cp2.Text = "";
            this.lB_cp3.Text = "";
            this.lB_cp4.Text = "";
            this.lB_cp5.Text = "";
            this.lB_cp6.Text = "";
            this.lB_cp7.Text = "";
            this.lB_cp8.Text = "";
            this.lB_cp9.Text = "";
            this.lB_cp10.Text = "";

        }

    }
}
